package com.teachoa.bean;

import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;

public class OrderLog extends Model<OrderLog> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7914607045864858634L;
	
	public static final OrderLog dao = new OrderLog();
	
	public OrderLog findOrderLogsByOIdAndTId(String orderId, String taskId) {
		return dao.findFirst("select * from order_log where order_id = ? and task_id = ? order by create_time desc", orderId, taskId);
	}
	
	public int getTotalSuccsByOIdAndNode(String orderId, int node) {
		String sql = "select count(*) as totalNum from order_log where order_id = ? and node = ? and flag = 1";
		return Db.findFirst(sql, orderId, node).getLong("totalNum").intValue();
	}
	
	public List<OrderLog> findOrderLogsByOId(String orderId) {
		String sql = "select * from order_log where order_id = ? order by create_time asc";
		return dao.find(sql, orderId);
	}

}
